package ro.sergiu.finder.ui;

import java.util.List;
import javax.swing.table.TableModel;
import ro.sergiu.finder.exception.EngineRunException;
import ro.sergiu.finder.filters.FilterField;
import ro.sergiu.finder.models.finder.FinderModel;

/**
 *
 * @author Toporjinschi
 */
public abstract class SearchEngineSpecifications {

    protected FinderModel model;
    protected List<FilterField> filterFields;

    /**
     * Sets the {@link FinderModel}
     *
     * @param model {@link FinderModel} is used to get information regarding the
     * columns which will be used, extra filters, 
     */
    public void setModel(FinderModel model) {
        this.model = model;
    }

    /**
     * Sets the filter field list
     *
     * @param filterFields a list of {@link FilterField} which will bound the
     * interface with the search engine. This is necessary because we have to
     * create the SQL statement based on what user inputs in search filter
     */
    public void setFilterFields(List<FilterField> filterFields) {
        this.filterFields = filterFields;
    }

    /**
     * This method will be triggered when the user is pressing search button
     *
     * @param searchTerm the search term value
     * @throws ro.sergiu.finder.exception.EngineRunException
     */
    public abstract void search(String searchTerm) throws EngineRunException;

    /**
     * @return the {@link TableModel} for the table which will be used to
     * display the results
     */
    public abstract TableModel getTableModel();

}
